﻿using Bloggie.Web.Data;
using Bloggie.Web.Models.Domain;

namespace Bloggie.Web.Repositories;

public class BlogPostRepository : IBlogPostRepository
{
    private readonly BloggieDbContext _bloggieDbContext;
    private IBlogPostRepository _blogPostRepositoryImplementation;

    public BlogPostRepository(BloggieDbContext bloggieDbContext)
    {
        _bloggieDbContext = bloggieDbContext;
    }

    public Task<IEnumerable<BlogPost>> GetAllAsync()
    {
        return _blogPostRepositoryImplementation.GetAllAsync();
    }

    public Task<BlogPost?> GetAsync(Guid id)
    {
        return _blogPostRepositoryImplementation.GetAsync(id);
    }

    public async Task<BlogPost> AddAsync(BlogPost blogPost)
    {
        await _bloggieDbContext.BlogPosts.AddAsync(blogPost);
        await _bloggieDbContext.SaveChangesAsync();
        return blogPost;
    }

    public Task<BlogPost?> UpdateAsync(BlogPost blogPost)
    {
        return _blogPostRepositoryImplementation.UpdateAsync(blogPost);
    }

    public Task<BlogPost?> DeleteAsync(Guid id)
    {
        return _blogPostRepositoryImplementation.DeleteAsync(id);
    }
}